package com.neusoft.restaurant.controller;

import com.neusoft.restaurant.config.utils.R;
import com.neusoft.restaurant.entity.PageResult;
import com.neusoft.restaurant.entity.ResAddress;
import com.neusoft.restaurant.service.IResAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 地址管理Controller
 * 
 * @author zhongda
 * @date 2023-12-10
 */
@RestController
@RequestMapping("/api/address")
public class ResAddressController extends BaseController
{
    @Autowired
    private IResAddressService resAddressService;

    /**
     * 查询地址管理列表
     */
    @GetMapping("/list")
    public R list(ResAddress resAddress)
    {

        List<ResAddress> list = resAddressService.selectResAddressList(resAddress);
        return R.success(list);
    }

    /**
     * 分页查询地址管理列表
     */
    @GetMapping("/list2")
    public R list2(ResAddress resAddress,Integer pageNum,Integer pageSize)
    {


        PageResult list = resAddressService.selectResAddressList2(resAddress,pageNum,pageSize);
        return R.success(list);


    }


    /**
     * 获取地址管理详细信息
     */
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Long id)
    {
        return R.success(resAddressService.selectResAddressById(id));
    }

    /**
     * 新增地址管理
     */
    @PostMapping
    public R add(@RequestBody ResAddress resAddress)
    {
        return R.toAjax(resAddressService.insertResAddress(resAddress));
    }

    /**
     * 修改地址管理
     */
    @PutMapping
    public R edit(@RequestBody ResAddress resAddress)
    {
        return R.toAjax(resAddressService.updateResAddress(resAddress));
    }

    /**
     * 删除地址管理
     */
	@DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids)
    {
        return R.toAjax(resAddressService.deleteResAddressByIds(ids));
    }
}
